.class public Lmyclass/updateManager;
.super Ljava/lang/Object;
.source "updateManager.java"


# static fields
.field private static final DOWN_OVER:I = 0x2

.field private static final DOWN_UPDATE:I = 0x1

.field private static final saveFileName:Ljava/lang/String; = "/sdcard/updatedemo/UpdateDemoRelease.apk"

.field private static final savePath:Ljava/lang/String; = "/sdcard/updatedemo/"


# instance fields
.field private apkUrl:Ljava/lang/String;

.field private downLoadThread:Ljava/lang/Thread;

.field private downloadDialog:Landroid/app/Dialog;

.field private interceptFlag:Z

.field private localVersion:I

.field private mContext:Landroid/content/Context;

.field private mHandler:Landroid/os/Handler;

.field private mProgress:Landroid/widget/ProgressBar;

.field private mdownApkRunnable:Ljava/lang/Runnable;

.field private noticeDialog:Landroid/app/Dialog;

.field private progress:I

.field private updateMsg:Ljava/lang/String;


# direct methods
.method public constructor <init>(Landroid/content/Context;I)V
    .locals 2
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "localVersion"    # I

    .prologue
    const/4 v1, 0x0

    .line 121
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 73
    const-string v0, "apk\u5185\u5bb9\u6709\u66f4\u65b0\u53ef\u4ee5\u4e0b\u8f7d\u6700\u65b0\u7248\u672c"

    iput-object v0, p0, Lmyclass/updateManager;->updateMsg:Ljava/lang/String;

    .line 76
    const-string v0, ""

    iput-object v0, p0, Lmyclass/updateManager;->apkUrl:Ljava/lang/String;

    .line 99
    iput-boolean v1, p0, Lmyclass/updateManager;->interceptFlag:Z

    .line 100
    iput v1, p0, Lmyclass/updateManager;->localVersion:I

    .line 102
    new-instance v0, Lmyclass/updateManager$1;

    invoke-direct {v0, p0}, Lmyclass/updateManager$1;-><init>(Lmyclass/updateManager;)V

    iput-object v0, p0, Lmyclass/updateManager;->mHandler:Landroid/os/Handler;

    .line 227
    new-instance v0, Lmyclass/updateManager$2;

    invoke-direct {v0, p0}, Lmyclass/updateManager$2;-><init>(Lmyclass/updateManager;)V

    iput-object v0, p0, Lmyclass/updateManager;->mdownApkRunnable:Ljava/lang/Runnable;

    .line 122
    iput-object p1, p0, Lmyclass/updateManager;->mContext:Landroid/content/Context;

    .line 123
    iput p2, p0, Lmyclass/updateManager;->localVersion:I

    .line 124
    return-void
.end method

.method static synthetic access$0(Lmyclass/updateManager;)Landroid/widget/ProgressBar;
    .locals 1

    .prologue
    .line 88
    iget-object v0, p0, Lmyclass/updateManager;->mProgress:Landroid/widget/ProgressBar;

    return-object v0
.end method

.method static synthetic access$1(Lmyclass/updateManager;)I
    .locals 1

    .prologue
    .line 95
    iget v0, p0, Lmyclass/updateManager;->progress:I

    return v0
.end method

.method static synthetic access$10(Lmyclass/updateManager;Ljava/lang/String;)V
    .locals 0

    .prologue
    .line 76
    iput-object p1, p0, Lmyclass/updateManager;->apkUrl:Ljava/lang/String;

    return-void
.end method

.method static synthetic access$11(Lmyclass/updateManager;)V
    .locals 0

    .prologue
    .line 205
    invoke-direct {p0}, Lmyclass/updateManager;->showDownloadDialog()V

    return-void
.end method

.method static synthetic access$12(Lmyclass/updateManager;Z)V
    .locals 0

    .prologue
    .line 99
    iput-boolean p1, p0, Lmyclass/updateManager;->interceptFlag:Z

    return-void
.end method

.method static synthetic access$2(Lmyclass/updateManager;)V
    .locals 0

    .prologue
    .line 287
    invoke-direct {p0}, Lmyclass/updateManager;->installApk()V

    return-void
.end method

.method static synthetic access$3(Lmyclass/updateManager;)V
    .locals 0

    .prologue
    .line 184
    invoke-direct {p0}, Lmyclass/updateManager;->showNoticeDialog()V

    return-void
.end method

.method static synthetic access$4(Lmyclass/updateManager;)Ljava/lang/String;
    .locals 1

    .prologue
    .line 76
    iget-object v0, p0, Lmyclass/updateManager;->apkUrl:Ljava/lang/String;

    return-object v0
.end method

.method static synthetic access$5(Lmyclass/updateManager;I)V
    .locals 0

    .prologue
    .line 95
    iput p1, p0, Lmyclass/updateManager;->progress:I

    return-void
.end method

.method static synthetic access$6(Lmyclass/updateManager;)Landroid/os/Handler;
    .locals 1

    .prologue
    .line 102
    iget-object v0, p0, Lmyclass/updateManager;->mHandler:Landroid/os/Handler;

    return-object v0
.end method

.method static synthetic access$7(Lmyclass/updateManager;)Z
    .locals 1

    .prologue
    .line 99
    iget-boolean v0, p0, Lmyclass/updateManager;->interceptFlag:Z

    return v0
.end method

.method static synthetic access$8(Lmyclass/updateManager;)Landroid/content/Context;
    .locals 1

    .prologue
    .line 70
    iget-object v0, p0, Lmyclass/updateManager;->mContext:Landroid/content/Context;

    return-object v0
.end method

.method static synthetic access$9(Lmyclass/updateManager;)I
    .locals 1

    .prologue
    .line 100
    iget v0, p0, Lmyclass/updateManager;->localVersion:I

    return v0
.end method

.method private downloadApk()V
    .locals 2

    .prologue
    .line 280
    new-instance v0, Ljava/lang/Thread;

    iget-object v1, p0, Lmyclass/updateManager;->mdownApkRunnable:Ljava/lang/Runnable;

    invoke-direct {v0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    iput-object v0, p0, Lmyclass/updateManager;->downLoadThread:Ljava/lang/Thread;

    .line 281
    iget-object v0, p0, Lmyclass/updateManager;->downLoadThread:Ljava/lang/Thread;

    invoke-virtual {v0}, Ljava/lang/Thread;->start()V

    .line 282
    return-void
.end method

.method private installApk()V
    .locals 4

    .prologue
    .line 288
    new-instance v0, Ljava/io/File;

    const-string v2, "/sdcard/updatedemo/UpdateDemoRelease.apk"

    invoke-direct {v0, v2}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 289
    .local v0, "apkfile":Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v2

    if-nez v2, :cond_0

    .line 296
    :goto_0
    return-void

    .line 292
    :cond_0
    new-instance v1, Landroid/content/Intent;

    const-string v2, "android.intent.action.VIEW"

    invoke-direct {v1, v2}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 293
    .local v1, "i":Landroid/content/Intent;
    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "file://"

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0}, Ljava/io/File;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v2

    const-string v3, "application/vnd.android.package-archive"

    invoke-virtual {v1, v2, v3}, Landroid/content/Intent;->setDataAndType(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;

    .line 294
    iget-object v2, p0, Lmyclass/updateManager;->mContext:Landroid/content/Context;

    invoke-virtual {v2, v1}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V

    goto :goto_0
.end method

.method private showDownloadDialog()V
    .locals 5

    .prologue
    .line 206
    new-instance v0, Landroid/app/AlertDialog$Builder;

    iget-object v3, p0, Lmyclass/updateManager;->mContext:Landroid/content/Context;

    invoke-direct {v0, v3}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V

    .line 207
    .local v0, "builder":Landroid/app/AlertDialog$Builder;
    const-string v3, "\u8f6f\u4ef6\u7248\u672c\u66f4\u65b0"

    invoke-virtual {v0, v3}, Landroid/app/AlertDialog$Builder;->setTitle(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;

    .line 209
    iget-object v3, p0, Lmyclass/updateManager;->mContext:Landroid/content/Context;

    invoke-static {v3}, Landroid/view/LayoutInflater;->from(Landroid/content/Context;)Landroid/view/LayoutInflater;

    move-result-object v1

    .line 210
    .local v1, "inflater":Landroid/view/LayoutInflater;
    const v3, 0x7f030058

    const/4 v4, 0x0

    invoke-virtual {v1, v3, v4}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v2

    .line 211
    .local v2, "v":Landroid/view/View;
    const v3, 0x7f070256

    invoke-virtual {v2, v3}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v3

    check-cast v3, Landroid/widget/ProgressBar;

    iput-object v3, p0, Lmyclass/updateManager;->mProgress:Landroid/widget/ProgressBar;

    .line 213
    invoke-virtual {v0, v2}, Landroid/app/AlertDialog$Builder;->setView(Landroid/view/View;)Landroid/app/AlertDialog$Builder;

    .line 214
    const-string v3, "\u53d6\u6d88"

    new-instance v4, Lmyclass/updateManager$6;

    invoke-direct {v4, p0}, Lmyclass/updateManager$6;-><init>(Lmyclass/updateManager;)V

    invoke-virtual {v0, v3, v4}, Landroid/app/AlertDialog$Builder;->setNegativeButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;

    .line 221
    invoke-virtual {v0}, Landroid/app/AlertDialog$Builder;->create()Landroid/app/AlertDialog;

    move-result-object v3

    iput-object v3, p0, Lmyclass/updateManager;->downloadDialog:Landroid/app/Dialog;

    .line 222
    iget-object v3, p0, Lmyclass/updateManager;->downloadDialog:Landroid/app/Dialog;

    invoke-virtual {v3}, Landroid/app/Dialog;->show()V

    .line 224
    invoke-direct {p0}, Lmyclass/updateManager;->downloadApk()V

    .line 225
    return-void
.end method

.method private showNoticeDialog()V
    .locals 3

    .prologue
    .line 185
    new-instance v0, Landroid/app/AlertDialog$Builder;

    iget-object v1, p0, Lmyclass/updateManager;->mContext:Landroid/content/Context;

    invoke-direct {v0, v1}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V

    .line 186
    .local v0, "builder":Landroid/app/AlertDialog$Builder;
    const-string v1, "\u8f6f\u4ef6\u7248\u672c\u66f4\u65b0"

    invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setTitle(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;

    .line 187
    iget-object v1, p0, Lmyclass/updateManager;->updateMsg:Ljava/lang/String;

    invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setMessage(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;

    .line 188
    const-string v1, "\u4e0b\u8f7d"

    new-instance v2, Lmyclass/updateManager$4;

    invoke-direct {v2, p0}, Lmyclass/updateManager$4;-><init>(Lmyclass/updateManager;)V

    invoke-virtual {v0, v1, v2}, Landroid/app/AlertDialog$Builder;->setPositiveButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;

    .line 195
    const-string v1, "\u4ee5\u540e\u518d\u8bf4"

    new-instance v2, Lmyclass/updateManager$5;

    invoke-direct {v2, p0}, Lmyclass/updateManager$5;-><init>(Lmyclass/updateManager;)V

    invoke-virtual {v0, v1, v2}, Landroid/app/AlertDialog$Builder;->setNegativeButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;

    .line 201
    invoke-virtual {v0}, Landroid/app/AlertDialog$Builder;->create()Landroid/app/AlertDialog;

    move-result-object v1

    iput-object v1, p0, Lmyclass/updateManager;->noticeDialog:Landroid/app/Dialog;

    .line 202
    iget-object v1, p0, Lmyclass/updateManager;->noticeDialog:Landroid/app/Dialog;

    invoke-virtual {v1}, Landroid/app/Dialog;->show()V

    .line 203
    return-void
.end method


# virtual methods
.method public checkUpdateInfo()V
    .locals 0

    .prologue
    .line 129
    invoke-virtual {p0}, Lmyclass/updateManager;->downupdate()Z

    .line 131
    return-void
.end method

.method public downupdate()Z
    .locals 1

    .prologue
    .line 135
    new-instance v0, Lmyclass/updateManager$3;

    invoke-direct {v0, p0}, Lmyclass/updateManager$3;-><init>(Lmyclass/updateManager;)V

    .line 180
    invoke-virtual {v0}, Lmyclass/updateManager$3;->start()V

    .line 181
    const/4 v0, 0x0

    return v0
.end method
